<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/* 	Class Name	: anggota
	Author 		: Iswan Putera S.Kom
	Version		: 1.0
	Date		: 22 May 2013
*/

class Anggota extends CI_Controller
{
	function __construct()
	{
		parent::__construct();	
		$this->load->model('main_model');
		$this->load->library('zetro_auth');
		$this->load->library('zetro_func');
		//force_ssl();
	}
//new member
function new_member()
{
		//menu header
		$data=array();
		$data['id_reg']=empty($_GET['id_reg'])?'':$_GET['id_reg'];
		$data['tab_header']=$this->zetro_form->generate_tab_header('New Member');
		$this->zetro_form->frm_file('asset/frm/zetro_member.frm');
		$this->zetro_auth->menus('new_member');
		$content='';
		$this->zetro_form->section('listmember');
		$this->zetro_form->action_col(true);
		$this->zetro_form->tabel_content($content);
		$data['list']=$this->zetro_form->list_std();
		$data['modal']=$this->zetro_form->dialog('','Member Detail');
		//send data to view
		$this->load->view('admin/header');
		$this->load->view('keanggotaan/new_member',$data);
		$this->load->view('admin/footer');
}
	function get_list_member()
	{
		/*show list data member yang ter registratsi
		 1. icon aksi akan di tampilkan sesuai dengan user yang aktif dan status dari id_reg tersebut.
		 2. jika user akti dalam group yang punya otorisasi edit dan status register tsb tidak C ( unupproved)
		    maka buton akan muncul 3 jenis [ process/view,edit,deleted]
		 3. jika user aktif masuk dalam daftar approver dan posisinya harus melakukan approved makan akan muncul
		    button process [cog-icon] dan sebaliknya akan muncul button veiw [zoom icon]
		 4. proses pencarian berdasarkan nama register yang memiliki phrase yang dikirim dari variable cari
		    dan data yang di tampilkan dari semua status 
		*/
		$content='';$i=0;$lst_usr=array();
		$ordby=empty($_POST['ordby'])?'id_reg':$_POST['ordby'];
		$this->main_model->table_name('v_member_reg');
		$this->main_model->query();
		if(empty($_POST['cari']))
		{
			(empty($_POST['sa']) || $_POST['sa']=='no')?
			$this->main_model->where_in('app_stat',array('R')):
			$this->main_model->where_in('app_stat',array('C'));
		}else{
			$this->main_model->where_like('nm_member',$_POST['cari'],'after');
		}
			
		$this->main_model->orderby($ordby);
		$this->main_model->set_methods('select_ordered');
		$lst_usr=$this->main_model->set_data();
		$this->zetro_auth->menus('new_member');
		foreach($lst_usr as $r)
		{
			$i++;
			$icon=($this->zetro_auth->cek_oto('e')!='' && $r->app_stat=='R')?
				  $this->zetro_form->z_icon($r->id_reg,array('cus-cog','cus-zoom','cus-cross'),array('activate','show_detail','deleted')):
				  $this->zetro_form->z_icon($r->id_reg,array('cus-zoom','cus-control-stop','cus-control-stop'),array('show_detail',''));
			$content.=tr().td($i,false,'','','center').
					  td($r->id_reg).td($r->nm_lokasi).
					  td($r->nm_member).td($r->sex_member,false,'','','center').
					  td($r->add_member).td($r->hp_member).
					  td($r->email_member).
					  td($icon,false,'','','center')._tr();
		}
			$content.=$this->zetro_form->DataNotFound($lst_usr,4);
			echo $content;
			
	}
	/**
	List member untuk setting simpanan
	@param =id_simpanan	
	@param =id_member
	@param =jml_simpanan
	*/
	function sett_simpanan()
	{
		//menu header
		$data=array();
		$data['id_reg']=empty($_GET['id_reg'])?'':$_GET['id_reg'];
		$data['tab_header']=$this->zetro_form->generate_tab_header('Setup Setoran');
		$this->zetro_form->frm_file('asset/frm/zetro_member.frm');//call file frm
		$this->zetro_auth->menus('setup_simpanan_anggota');//set autorisasi menu
		$content='';
		$this->zetro_form->section('frmlokasi');
		$data['simp']=$this->zetro_form->generate_dropdown_content('simpanan_jenis','id_simpanan','nm_simpanan');
		$data['frm3']=$this->zetro_form->frmInline('frm5',true);
		$this->zetro_form->section('setsimpanan');
		$this->zetro_form->action_col(true);
		$this->zetro_form->tabel_content($content);
		$data['list']=$this->zetro_form->list_std();
			//create popup window
			$this->zetro_form->addButtons(false);
			$this->zetro_form->buttons(true,'Simpan');
			$this->zetro_form->section('frmsetsimpanan');
			$data['modal']=$this->zetro_form->dialog($this->zetro_form->frm_std('frm2'),'Setup Simpanan');
			
			$data['frm2']=$this->zetro_form->frm_std('frm2');
			$data['lok']=$this->zetro_form->generate_dropdown_content('lokasi','id_lokasi','nm_lokasi');
		//send data to view
		$this->load->view('admin/header');
		$this->load->view('keanggotaan/setup_simpanan',$data);
		$this->load->view('admin/footer');
	}
	function get_aktif_member()
	{
		$content='';$i=0;$lst_usr=array();
		$ordby=empty($_POST['ordby'])?'nm_member':$_POST['ordby'];
		$this->main_model->table_name('anggota_v');
		$this->main_model->query();
		if(empty($_POST['cari']))
		{
			empty($_POST['id_cabang'])?
			$this->main_model->where_in('app_stat',array('Y')):
			$this->main_model->where(array('app_stat'=>'Y','id_lokasi'=>$_POST['id_cabang']));
		}else{
			$this->main_model->where_like('nm_member',$_POST['cari'],'after');
		}
		$this->main_model->where(array('status_member'=>'A'));
		$this->main_model->orderby($ordby);
		$this->main_model->set_methods('select_ordered');
		$lst_usr=$this->main_model->set_data();
		$this->zetro_auth->menus('setup_simpanan_anggota');
		foreach($lst_usr as $r)
		{
			$i++;$j_simp=0;$c_bayar='1';
			/** cek jumlah simpanan*/
			if (!empty($_POST['c_bayare']))
			{
				$this->main_model->where(array('c_bayar'=>$_POST['c_bayare']));
			}
			$j_simp=$this->main_model->get_db('member_set_simpanan',array('id_member'=>$r->id_reg,'id_simpanan'=>$_POST['id_simpanan']),'val_simpanan');
			/** pastikan otorisasi user */
			$onclick=($this->zetro_auth->cek_oto('e')!='')?"_aksi('".$r->id_reg."','add')":"";
			$onclick2=($this->zetro_auth->cek_oto('e')!='')?"_aksi('".$r->id_reg."','del')":"";
			/** cek cara pembayaran */
			$c_bayar=$this->main_model->get_db('member_set_simpanan',array('id_member'=>$r->id_reg,'id_simpanan'=>$_POST['id_simpanan']),'c_bayar');
			$select1=($c_bayar=='1')?"selected='selected'":"";
			$select2=($c_bayar=='2')?"selected='selected'":"";
			$inline="<div class='input-append'>";
			$inline.="<input type='text' readonly id='".str_replace('-','',$r->id_reg)."' name='".str_replace('-','',$r->id_reg)."' class='span2 angka' placeholder='Jumlah Simpanan' value='".number_format($j_simp,0)."'/>";
			$inline.=($this->zetro_auth->cek_oto('e')!='')?"<span class='add-on' onclick=\"$onclick\"><i class='cus-cog'></i></span>":'';
			$inline.=($this->zetro_auth->cek_oto('e')!='')?"<span class='add-on' onclick=\"$onclick2\"><i class='cus-cross'></i></span>":'';
			$inline.="</div>";
			$icon=($this->zetro_auth->cek_oto('e')!='')?
				  $this->zetro_form->z_icon($r->id_reg,array('cus-folder','cus-zoom','cus-cross'),array('update','show_detail','deleted')):
				  $this->zetro_form->z_icon($r->id_reg,array('cus-zoom','cus-control-stop','cus-control-stop'),array('show_detail',''));
			
			$content.=tr().td($i,'',false,'','center').
					  td($r->id_reg).
					  td($r->nm_member).
					  td(number_format($j_simp,0)/*$inline*/,'',false,'','right').
					  td(($c_bayar=='1')?'Tunai':'Transfer','',false,'','center').
					  td($icon,'5%',false,'','center').
					  _tr();
		}
			$content.=$this->zetro_form->DataNotFound($lst_usr,5);
			echo $content;
	}
	function setsetupsimpanan()
	{
		$data=array();
		$ordby=empty($_POST['ordby'])?'nm_member':$_POST['ordby'];
		$this->main_model->table_name('anggota_v');
		$this->main_model->query();
		empty($_POST['id_cabang'])?
			$this->main_model->where_in('app_stat',array('Y')):
			$this->main_model->where(array('app_stat'=>'Y','id_lokasi'=>$_POST['id_cabang']));
		$this->main_model->orderby($ordby);
		$this->main_model->set_methods('select_ordered');
		$lst_usr=$this->main_model->set_data();
		$all=empty($_POST['allm'])?'':$_POST['allm'];
		if($all=='')
		{
			$data['id_member']=$_POST['id_member'];
			$data['id_simpanan']=$_POST['j_simpanan'];
			$data['val_simpanan']=empty($_POST['jml_simpanan'])?'0':str_replace(',','',$_POST['jml_simpanan']);
			$data['c_bayar']=empty($_POST['c_bayar'])?'2':$_POST['c_bayar'];
			$data['created_by']=$this->session->userdata('userid');
			$this->main_model->prepared_data('member_set_simpanan',$data);
			echo success($this->main_model->set_data());
		}else{
			foreach($lst_usr as $r)
			{
				$data['id_member']=$r->id_reg;
				$data['id_simpanan']=$_POST['j_simpanan'];
				$data['val_simpanan']=empty($_POST['jml_simpanan'])?'0':str_replace(',','',$_POST['jml_simpanan']);
				$data['c_bayar']=empty($_POST['c_bayar'])?'2':$_POST['c_bayar'];
				$data['created_by']=$this->session->userdata('userid');
				$this->main_model->prepared_data('member_set_simpanan',$data);
				$xx=success($this->main_model->set_data());
					
			}
			echo $xx;
		}
	}
	
	function delsetupsimpanan()
	{
		$id=$_POST['id_member'];
		$this->main_model->table_name('member_set_simpanan');
		$this->main_model->set_methods('delete');
		$this->main_model->where(array('id_member'=>$_POST['id_member'],'id_simpanan'=>$_POST['id_simpanan']));
		echo success($this->main_model->set_data());	
	}
	
	function getdetailsetupsimpanan()
	{
		$lst_usr=array();
		$id=$_POST['id_member'];
		$ids=empty($_POST['id_simpanan'])?'1':$_POST['id_simpanan'];
		$ordby=empty($_POST['ordby'])?'nm_member':$_POST['ordby'];
		$this->main_model->table_name('v_member_sp');
		$this->main_model->query();
		$this->main_model->where(array('id_reg'=>$id,'id_simpanan'=>$ids));
		$this->main_model->orderby($ordby);
		$this->main_model->set_methods('select_ordered');
		$lst_usr=$this->main_model->set_data();
		echo ($lst_usr)?json_encode($lst_usr[0]):$this->_getnewsetsimpanan($id);
	}
	function _getnewsetsimpanan($id='')
	{
		$this->main_model->table_name('anggota');
		$this->main_model->where(array('id_reg'=>$id));
		$this->main_model->orderby();
		$this->main_model->query();
		$this->main_model->set_methods('select');
		$lst_usr=$this->main_model->set_data();
		echo json_encode($lst_usr[0]);	
	}
	
/**
	Daftar aktif member atau member yang dinyatakan aktif
	proses menjadi member aktif jika sudah melakukan pembayaran uang pendaftaran dan simpanan pokok
	proses pemindahan data dari tabel member ke tabel anggota dilakukan by trigger t_member_upd jika status berganti ke Y
*/
	function list_aktiv_member()
	{
		$data=array();
		$fld="<span class='add-on'>Cabang</span><select class='span2' id='id_lokasi' name='id_lokasi'>".
		$this->zetro_form->generate_dropdown_content('v_lokasi','id_lokasi','nm_lokasi')."</select>";
		$fld.=(@$_GET['rpt']=='y')?"<input type='button' class='btn' id='prn' value='Print'/>":"";
		$fld.="</div><div class='input-append pull-right'>
				<input type='search' class='span3' id='cari' name='cari' value='' placeholder='Find by name'/>
				<button class='btn' type='button' id='c_cari'>GO</button>";
		$this->zetro_form->AddFilter($this->zetro_form->AddUb($this->zetro_form->fld($fld,true)));
		$data['tab_header']=$this->zetro_form->generate_tab_header('Active Member',true);
		$this->zetro_form->frm_file('asset/frm/zetro_member.frm');//call file frm
		$this->zetro_auth->menus('active_member_list');//set autorisasi menu
		$content='';
		$this->zetro_form->section('headmember');
		$data['frm3']=$this->zetro_form->frmInline('frm1',true,false,true);
		//$data['area']=$this->zetro_auth->cek_area();
		$data['lok'] =$this->zetro_form->generate_dropdown_content('lokasi','id_lokasi','nm_lokasi');
		$this->zetro_form->section('listmember');
		$this->zetro_form->action_col(true);
		$this->zetro_form->tabel_content($content);
		$data['list']=$this->zetro_form->list_std();
		//$data['list']=$this->zetro_form->list_grid();
		$data['modal']=$this->zetro_form->dialog('','Update Anggota','',true,'',(@$_GET['rpt']=='y')?false:false);
		$data['modal2']=$this->zetro_form->PrintPreview('List Anggota');
		$this->load->view('admin/header');
		$this->load->view('keanggotaan/aktive_member',$data);
		$this->load->view('admin/footer');
	}
	
	function get_list_aktiv_member()
	{
		$content='';$i=0;$lst_usr=array();
		$ordby=empty($_POST['ordby'])?'nm_member':$_POST['ordby'];
		$this->zetro_auth->menus('active_member_list');
		$this->main_model->table_name('anggota_v');
		$this->main_model->query();
		if(empty($_POST['cari']))
		{
			(empty($_POST['id_lokasi'])||$_POST['id_lokasi']=='')?'':
			$this->main_model->where(array('id_lokasi'=>$_POST['id_lokasi']));
		}else{
			$this->main_model->where_like('nm_member',$_POST['cari'],'after');
		}/**/
		$this->main_model->where(array('app_stat <>'=>'D','status_member <>'=>'N'));
		$this->main_model->orderby($ordby);
		$this->main_model->set_methods('select_ordered');
		$lst_usr=$this->main_model->set_data();
		foreach($lst_usr as $r)
		{
			$i++;
			$icon=($this->zetro_auth->cek_oto('e')!='')?
				  $this->zetro_form->z_icon($r->id_reg,array('cus-folder','cus-zoom','cus-cross'),array('update','show_detail','deleted')):
				  $this->zetro_form->z_icon($r->id_reg,array('cus-zoom','cus-control-stop','cus-control-stop'),array('show_detail',''));
			$content.=tr().td($i,'',false,'','center').
					  td($this->main_model->get_db('lokasi',array('id_lokasi'=>$r->id_lokasi),'nm_lokasi')).
					  td($r->id_reg,'',false,'','center').
					  td($r->nm_member).
					  td($r->sex_member.'',false,'center').
					  td($r->add_member).
					  td($r->hp_member).
					  td($r->email_member).
					  td((@$_GET['rpt']=='y')?'':$icon,false,'center').
					  _tr();
		}
			$content.=$this->zetro_form->DataNotFound($lst_usr,5);
			echo $content;
	}
	function printaktivmember()
	{
		$content='';$i=0;$lst_usr=array();
		$ordby=empty($_POST['ordby'])?'nm_member':$_POST['ordby'];
		$this->zetro_auth->menus('active_member_list');
		$this->main_model->table_name('anggota');
		$this->main_model->query();
		if(empty($_POST['cari']))
		{
			(empty($_POST['id_lokasi'])||$_POST['id_lokasi']=='')?'':
			$this->main_model->where(array('id_lokasi'=>$_POST['id_lokasi']));
		}else{
			$this->main_model->where_like('nm_member',$_POST['cari'],'after');
		}/**/
		$this->main_model->where(array('app_stat <>'=>'D'));
		$this->main_model->orderby($ordby);
		$this->main_model->set_methods('select_ordered');
		$data['id_lokasi']=empty($_POST['id_lokasi'])?'All':$this->main_model->rdb('lokasi','nm_lokasi',"where id_lokasi='".$_POST['id_lokasi']."'");
		$data['lst_usr']=$this->main_model->set_data();
		//generate PDF
		$this->load->library('zetro_dompdf');
		$html = $this->load->view('keanggotaan/aktive_member_print', $data, true);
		$this->zetro_dompdf->createPDF($html, $this->session->userdata('userid').'aktive_member_print', true,'protrait','A4');
		echo base_url().'application/logs/'.$this->session->userdata('userid').'aktive_member_print.pdf';/**/
		
	}
	function get_detail_aktiv_member()
	{
		$id=$_POST['id_member'];
		$this->main_model->table_name('anggota_v');
		$this->main_model->query();
		$this->main_model->where(array('id_reg'=>$id));
		$this->main_model->set_methods('select');
		$lst_usr=$this->main_model->set_data();
		echo json_encode($lst_usr[0]);
		//$this->load->view('keanggotaan/detail_new_member',$lst_usr[0]);
	}
	function update_member()
	{
		$data=array();
		$data['id_mm']=empty($_POST['id_member'])?'':$_POST['id_member'];
		//menu header
		$data['tab_header']=$this->zetro_form->generate_tab_header('Update Anggota');
		//generate form basic data
		$this->zetro_form->frm_file('asset/frm/zetro_member.frm');
		$this->zetro_form->section('anggota');
		$this->zetro_auth->menus('active_member_list');
		$this->zetro_form->generate_dropdown_content('lokasi','id_lokasi','nm_lokasi','','id_lokasi');
	    $this->zetro_form->addButtons();
		$this->zetro_form->buttons(false,'Save + Next');
		$data['form']=$this->zetro_form->frm_std('frm2');
		//generat personal form
		$this->zetro_form->section('anggota1');
		$this->zetro_auth->menus('active_member_list');
		$this->zetro_form->buttons(false,'Saved');
		$data['form2']=$this->zetro_form->frm_std('frm3');
		$this->zetro_form->section('anggota3');
		$this->zetro_auth->menus('active_member_list');
		$this->zetro_form->buttons(false,'Saved');
		$data['form3']=$this->zetro_form->frm_std('frm4');
		$data['aksi']=$_POST['aksi'];
		//send data to view
		//$this->load->view('admin/header');
		$this->load->view('keanggotaan/update_anggota',$data);
		//$this->load->view('admin/footer');
	}
	function setupdatemember()
	{
		$data=array();$datax=array();
		$data['id_reg']=$_POST['id_reg'];
		$data['id_lokasi']=empty($_POST['id_lokasi'])?'0001':$_POST['id_lokasi'];
		$data['nip_member']=empty($_POST['nip_member'])?'':$_POST['nip_member'];	
		$data['nm_member']=empty($_POST['nm_member'])?'':$_POST['nm_member'];	
		$data['sex_member']=empty($_POST['sex_member'])?'L':$_POST['sex_member'];	
		$data['bop_member']=empty($_POST['bop_member'])?'':$_POST['bop_member'];	
		$data['bod_member']=empty($_POST['bod_member'])?'0000-00-00':tglToSql($_POST['bod_member']);	
		$data['add_member']=empty($_POST['add_member'])?'':$_POST['add_member'];	
		$data['hp_member']=empty($_POST['hp_member'])?'':$_POST['hp_member'];
		$data['email_member']=empty($_POST['email_member'])?'':$_POST['email_member'];
		$data['app_stat']=$this->main_model->get_db("anggota",array('id_reg'=>$_POST['id_reg']),'app_stat');
		$data['created_by']=$this->session->userdata('userid');
		$this->main_model->prepared_data('anggota',$data);
		echo success($this->main_model->set_data());
		//tab2	
		$datax['no_anggota']=$_POST['id_reg'];
		$datax['tgl_masuk']=empty($_POST['tgl_masuk'])?'0000-00-00':tglToSql($_POST['tgl_masuk']);	
		$datax['status_member']=empty($_POST['status_member'])?'A':$_POST['status_member'];	
		$datax['tgl_keluar']=empty($_POST['tgl_keluar'])?'0000-00-00':tglToSql($_POST['tgl_keluar']);
		$datax['kode_kantor']=empty($_POST['kode_kantor'])?'':$_POST['kode_kantor'];	
		$datax['bagian']=empty($_POST['bagian'])?'':$_POST['bagian'];	
		$datax['no_gaji']=empty($_POST['no_gaji'])?'':$_POST['no_gaji'];	
		$datax['rekening']=empty($_POST['rekening'])?'':$_POST['rekening'];
		$datax['nm_rekbank']=empty($_POST['nm_rek'])?'':$_POST['nm_rek'];
		$datax['rekpribadi']=empty($_POST['rekpribadi'])?'':$_POST['rekpribadi'];
		$datax['nm_rekpri']=empty($_POST['nm_rekpri'])?'':$_POST['nm_rekpri'];
		//tab3
		/*$datax['simpanan_pokok']=empty($_POST['simpanan_pokok'])?'0':str_replace(",","",$_POST['simpanan_pokok']);
		$datax['saldo_wajib']=empty($_POST['saldo_wajib'])?'0':str_replace(",","",$_POST['saldo_wajib']);
		$datax['saldo_sukarela']=empty($_POST['saldo_sukarela'])?'0':str_replace(",","",$_POST['saldo_sukarela']);
		$datax['saldo_pinjaman_uang']=empty($_POST['saldo_pinjaman_uang'])?'0':str_replace(",","",$_POST['saldo_pinjaman_uang']);
		$datax['saldo_pinjaman_barang']=empty($_POST['saldo_pinjaman_barang'])?'0':str_replace(",","",$_POST['saldo_pinjaman_barang']);
		*/
		$this->main_model->prepared_data('anggota_detail',$datax);
		echo success($this->main_model->set_data());
		//tab3
		
	}
	function non_aktif_member()
	{
		$id=$_POST['id_member'];
		$this->main_model->table_name('anggota');
		$this->main_model->where(array('id_reg'=>$id));
		$this->main_model->query();
		$this->main_model->get_content(array('app_stat'=>'C'));
		$this->main_model->set_methods('update');
		$lst_usr=$this->main_model->set_data();
	}
	//show simpanan member
	function detail_member_data()
	{
		//menu header
		$data=array();
		$data['tab_header']=$this->zetro_form->generate_tab_header('Account Member');
		$this->zetro_form->frm_file('asset/frm/zetro_member.frm');//call file frm
		$this->zetro_auth->menus('saldo_simpanan');//set autorisasi menu
		$content='';
		(@$_GET['rpt']=='y')?
		$this->zetro_form->section('headmemberprint'):
		$this->zetro_form->section('headmember');
		$data['lok'] =$this->zetro_form->generate_dropdown_content('lokasi','id_lokasi','nm_lokasi');
		$data['frm3']=$this->zetro_form->frmInline('frm1',true,false,true);
		$this->zetro_form->section('akunmember');
		$this->zetro_form->action_col(false);
		$this->zetro_form->tabel_content($content);
		$data['list']=$this->zetro_form->list_std();
		$data['modal']=$this->zetro_form->PrintPreview('List Anggota');
		$this->load->view('admin/header');
		$this->load->view('keanggotaan/account_member',$data);
		$this->load->view('admin/footer');
	}
	function getjenissimpanan()
	{
		$this->main_model->table_name('simpanan_jenis');
		$this->main_model->query();
		$this->main_model->set_methods('select');
		$lst_usr=$this->main_model->set_data();
		$html=tr('alert-info');
		foreach($lst_usr as $r)
		{
			$html.=td($r->nm_simpanan,'',true);
		}
		$html.=_tr();
		echo $html;
	}
	function getsaldosimpanan()
	{
		$content='';$i=0;$lst_usr=array();
		$ordby=empty($_POST['ordby'])?'nm_member':$_POST['ordby'];
		$this->zetro_auth->menus('saldo_simpanan');
		$this->main_model->table_name('anggota_v_sk');
		$this->main_model->query();
		if(empty($_POST['cari']))
		{
			(empty($_POST['id_lokasi'])||$_POST['id_lokasi']=='')?'':
			$this->main_model->where(array('id_lokasi'=>$_POST['id_lokasi']));
		}else{
			$this->main_model->where_like('nm_member',$_POST['cari'],'both');
		}/**/
		$this->main_model->orderby($ordby);
		$this->main_model->set_methods('select_ordered');
		$lst_usr=$this->main_model->set_data();
		$sp=0;$sw=0;$ss=0;$spb=0;$spt=0;$spk=0;
		foreach($lst_usr as $r)
		{
			$i++;
			$content.=tr().td($i,'',false,'','center').
					  td($r->id_reg,'',false,'','center').
					  td($r->nm_member,'',false,'','\' nowrap=\'nowrap').
					  td(number_format((int)$r->simpanan_pokok,2),'',false,'','right').
					  td(number_format((int)$r->saldo_wajib,2),'',false,'','right').
					  td(number_format((int)$r->saldo_sukarela,2),'',false,'','right').
					  td(number_format((int)$r->saldo_pinjaman_barang,2),'',false,'','right').
					  td(number_format((int)$r->saldo_pinjaman_uang,2),'',false,'','right').
					  td(number_format((int)$r->saldo_pinj_nonkredit,2),'',false,'','right').
					 _tr();
					$sp +=(int)$r->simpanan_pokok;
					$sw +=(int)$r->saldo_wajib;
					$ss +=(int)$r->saldo_sukarela;
					$spb +=(int)$r->saldo_pinjaman_barang;
					$spt +=(int)$r->saldo_pinjaman_uang;
					$spk +=(int)$r->saldo_pinj_nonkredit;
		
		}
			if($lst_usr)
			{$content.=tr().td('<b>TOTAL :','',false,'','right\' colspan=\'3').
					   td(number_format($sp,2),'',false,'','right').
					   td(number_format($sw,2),'',false,'','right').
					   td(number_format($ss,2),'',false,'','right').
					   td(number_format($spb,2),'',false,'','right').
					   td(number_format($spt,2),'',false,'','right').
					   td(number_format($spk,2),'',false,'','right').
					   _tr();
			}
			$content.=$this->zetro_form->DataNotFound($lst_usr,8);
			echo $content;
	}
	function printsaldosimpanan()
	{
		$data=array();
		$content='';$i=0;$lst_usr=array();
		$ordby=empty($_POST['ordby'])?'nm_member':$_POST['ordby'];
		$this->zetro_auth->menus('saldo_simpanan');
		$this->main_model->table_name('anggota_v_sk');
		$this->main_model->query();
		if(empty($_POST['cari']))
		{
			(empty($_POST['id_lokasi'])||$_POST['id_lokasi']=='')?'':
			$this->main_model->where(array('id_lokasi'=>$_POST['id_lokasi']));
		}else{
			$this->main_model->where_like('nm_member',$_POST['cari'],'after');
		}/**/
		$this->main_model->orderby($ordby);
		$this->main_model->set_methods('select_ordered');
		$data['id_lokasi']=empty($_POST['id_lokasi'])?'All':
			$this->main_model->rdb('lokasi','nm_lokasi',"where id_lokasi='".$_POST['id_lokasi']."'");
		$data['lst_usr']=$this->main_model->set_data();
		$this->main_model->table_name('simpanan_jenis');
		$this->main_model->query();
		$this->main_model->set_methods('select');
		$data['simp']=$this->main_model->set_data();
		//generate PDF
		$this->load->library('zetro_dompdf');
		$html = $this->load->view('keanggotaan/account_member_print', $data, true);
		//echo $html;
		$this->zetro_dompdf->createPDF($html, $this->session->userdata('userid').'account_member_print', true,'landscape','A4');
		echo base_url().'application/logs/'.$this->session->userdata('userid').'account_member_print.pdf';/**/
	}
	function printdetailmember()
	{
		$id_reg=$_POST['id_reg'];
		$this->main_model->table_name('anggota_v');
		$this->main_model->query();
		$this->main_model->where(array('id_reg'=>$id_reg));
		$this->main_model->set_methods('select');
		$data['lst_usr']=$this->main_model->set_data();
		//generate PDF
		$this->load->library('zetro_dompdf');
		$html = $this->load->view('keanggotaan/member_detail_print', $data, true);
		$this->zetro_dompdf->createPDF($html, $this->session->userdata('userid').'_member_detail_print', true,'protrait','A4');
		echo base_url().'application/logs/'.$this->session->userdata('userid').'_member_detail_print.pdf';/**/
	}
//end of anggota class
}

?>
